def find_string_anagrams(str1, pattern):
  result_indexes = []
  start = 0
  matched  = 0
  chr_frequency = {}

  for char in pattern:
    if char not in chr_frequency:
      chr_frequency[char] = 0
    chr_frequency[char] += 1
  
  for end in range(len(str1)):
    right_chr = str1[end]
    if right_chr in pattern:
      chr_frequency[right_chr] -= 1
    if chr_frequency[right_chr] == 0:
      matched += 1

    if matched == len(chr_frequency):
      result_indexes.append(start)

    if end >= (len(pattern)-1):
      left_chr = str1[start]
      start += 1
      if left_chr in pattern:
        if chr_frequency[left_chr] == 0:
          matched -= 1
        chr_frequency[left_chr] += 1    
  # TODO: Write your code here
  return result_indexes

def main():
  print(find_string_anagrams("ppqp", "pq"))
  print(find_string_anagrams("abbcabc", "abc"))


main()